package com.linsir.auth.modules.oauth.controller;

import com.linsir.auth.dto.TDto;
import com.linsir.auth.modules.oauth.service.IdentityService;
import com.linsir.auth.modules.test.entity.Identity;
import com.linsir.auth.vo.StaffVO;
import com.linsir.core.binding.binder.remote.RemoteBindDTO;
import com.linsir.core.controller.BaseCrudRestController;
import com.linsir.core.util.JSON;
import com.linsir.core.vo.Status;
import com.linsir.core.vo.jsonResults.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName : TController
 * @Description :
 * @Author : Linsir
 * @Date: 2023-12-22 15:57
 */

@RestController
@RequestMapping("/")
public class TController extends BaseCrudRestController<Identity> {

    @Autowired
    private IdentityService identityService;

    @GetMapping("tt")
    public String tt()
    {
        return "tttttt";
    }


    @RequestMapping("/e")
    public void e(HttpRequest httpRequest, HttpResponse httpResponse)
    {
        System.out.println("xxx");
    }


    @GetMapping("getT")
    public void getT()
    {
        TDto tDto = new TDto("linsir");

        StaffVO staffVO = new StaffVO();
        System.out.println(tDto.getWm());
    }

    @RequestMapping("/common/remoteBinding")
    public JsonResult<String> loadBindingData(RemoteBindDTO remoteBindDTO)
    {
        JsonResult<String> result = new JsonResult<>();
        result.status(Status.OK);
        List<Map<String,Object>> list = new ArrayList<Map<String,Object>>(4);

        Map<String,Object> map = new HashMap<>();
        /*Person person = new Person();
        person.setId(1);
        person.setName("xxxxxxxxxx");*/
        map.put("id",1);
        map.put("name","xxxxx");
        list.add(map);
        result.data(JSON.stringify(list));
        return result;
    }
    @GetMapping("get")
    public Identity get()
    {

       return identityService.getEntity(1);
    }
}
